package dk.pun.aot.client;

import java.util.Date;

import com.google.gwt.user.client.Cookies;

public class AnonymousLogin {

	private static final String cookieName = "ANONLOGIN";
	private static final int loginExpiration = 3600000;
	
	public static void login() {
		Date date = new Date(System.currentTimeMillis() + loginExpiration);
		Cookies.setCookie(cookieName, Boolean.TRUE.toString(), date);
	}
	
	public static void logout() {
		Cookies.removeCookie(cookieName);
	}
	
	public static boolean isLoggedIn() {
		boolean loggedIn = false;
		String cookieValue = Cookies.getCookie(cookieName);
		if (cookieValue != null && Boolean.valueOf(cookieValue)) {
			loggedIn = true;
		}
		return loggedIn;
	}
}
